<template>
  <a-modal
    :visible="visibleSaveOrEdit"
    title="新增法人验收"
    cancelText="返回"
    okText="确定"
    @ok="submit"
    @cancel="cancel"
    width="calc(100% - 240px)"
    :style="{top: '0px', 'margin-left': '240px', maxWidth: '100vw', height: 'calc(100% - 132px)'}"
  >
    <a-form
      ref="formRef"
      :model="formState"
    >
      <a-row style="width: 100%; height: 100%;">
        <a-form-item label="分部工程验收资料">
          <div>
            <a-upload
              :action="actionUrl"
              :multiple="true"
              v-model:file-list="fileListfbs"
              :headers="headers"
              accept=".jpg, .jpeg, .png, .pdf, .doc, .docx, .wps"
              class="xmjcfile"
              :customRequest="uploadFile('fb')"
            >
              <a-button type="primary">
                <upload-outlined></upload-outlined>
                上传文件
              </a-button>
            </a-upload>
            <a-input type="hidden" v-model:value="formState.fenbuyanshou" id="fenbuyanshou" name="fenbuyanshou"/>
          </div>
        </a-form-item>
      </a-row>
    </a-form>
  </a-modal>
</template>

<script>
  import {createVNode, defineComponent, reactive, ref, toRaw, watch} from "vue";

  export default defineComponent({
    props: {
      visibleSaveOrEdit: {
        type: Boolean,
      },
      record: {
        type: Object,
      }
    },
    emit: ["close"],
    setup(props, context) {
      const formRef = ref();

      const state = reactive({})

      const formState = reactive({});

      const tokenKey = localStorage.getItem("token_key");
      const token = localStorage.getItem("token")
      const headers = {
        "Authorization": token,
        "Authorization-key": tokenKey
      };

      const fileListfbs = ref([]);
      const fileListdws = ref([]);
      const fileListhts = ref([]);
      const fileListqts = ref([]);

      const actionUrl = () => {
        return "http://localhost:9292/api/project/frys/upload";
      }

      const submit = (e) => {
        cancel();
      }

      const cancel = (e) => {
        formRef.value.resetFields();
        context.emit("close", false);
      };

      const uploadFile = (e) => {
        const form = new FormData();
      }

      return {
        state,
        formRef,
        formState,
        submit,
        cancel,

        headers,

        actionUrl,
        fileListfbs,
        fileListdws,
        fileListhts,
        fileListqts,

        uploadFile,
      }
    }
  })
</script>

<style scoped>
  /* 文件上传样式 */
  .xmjcfile :deep(.ant-upload-list) {
    width: 1478px;
    margin-bottom: 20px;
  }
</style>
